const initialCounter = {
    counter: 0
}

function counterReducer(state = initialCounter, action) {
    switch (action.type) {
        case ADD_NUMBER:
            return { ...state, counter: state.counter + action.num };
        case SUB_NUMBER:
            return { ...state, counter: state.counter - action.num };
        default:
            return state;
    }
}

const initialHome = {
    banners: [],
    recommends: []
}

function homeReducer(state = initialHome, action) {
    switch (action.type) {
        case CHANGE_BANNER:
            return { ...state, banners: action.banners };
        case CHANGE_RECOMMEND:
            return { ...state, recommends: action.recommends };
        default:
            return state;
    }
}

const initialState = {
}

function reducer(state = initialState, action) {
    return {
        counterInfo: counterReducer(state.counterInfo, action),
        homeInfo: homeReducer(state.homeInfo, action),
    }
}